package com.mebs.edi.model.edi.e214;

import javax.persistence.Embeddable;
import javax.persistence.Embedded;

import com.mebs.edi.model.dom.DomChild;
import com.mebs.edi.model.dom.DomEntity;

/**
 * 
 * N section of a 214 EDI file 
 * 
 * @author nit
 *
 */
@Embeddable
@DomEntity(name = "N")
public class Edi214Nn {
	
	public enum Nn214Qualifier {
		SHIPMENT_DEPARTURE("PW"), 
		SHIPMENT_ARRIVAL("ST");
		
		private String code;
		
		Nn214Qualifier(String code) {
			this.code = code;
		}
		
		public String getCode() {
			return code;
		}
	}
	
	@Embedded
	@DomChild
	private Edi214N1 n1;
	
	@Embedded
	@DomChild
	private Edi214N3 n3;
	
	@Embedded
	@DomChild
	private Edi214N4 n4;
	
	@Embedded
	@DomChild
	private Edi214G62 g62;
	
	public Edi214Nn() {
		super();
	}

	public Edi214N1 getN1() {
		return n1;
	}

	public void setN1(Edi214N1 n1) {
		this.n1 = n1;
	}

	public Edi214N3 getN3() {
		return n3;
	}

	public void setN3(Edi214N3 n3) {
		this.n3 = n3;
	}

	public Edi214N4 getN4() {
		return n4;
	}

	public void setN4(Edi214N4 n4) {
		this.n4 = n4;
	}

	public Edi214G62 getG62() {
		return g62;
	}

	public void setG62(Edi214G62 g62) {
		this.g62 = g62;
	}

	@Override
	public String toString() {
		return "Edi214Nn [n1=" + n1 + ", n3=" + n3 + ", n4=" + n4 + ", g62=" + g62 + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((g62 == null) ? 0 : g62.hashCode());
		result = prime * result + ((n1 == null) ? 0 : n1.hashCode());
		result = prime * result + ((n3 == null) ? 0 : n3.hashCode());
		result = prime * result + ((n4 == null) ? 0 : n4.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Edi214Nn other = (Edi214Nn) obj;
		if (g62 == null) {
			if (other.g62 != null)
				return false;
		} else if (!g62.equals(other.g62))
			return false;
		if (n1 == null) {
			if (other.n1 != null)
				return false;
		} else if (!n1.equals(other.n1))
			return false;
		if (n3 == null) {
			if (other.n3 != null)
				return false;
		} else if (!n3.equals(other.n3))
			return false;
		if (n4 == null) {
			if (other.n4 != null)
				return false;
		} else if (!n4.equals(other.n4))
			return false;
		return true;
	}
}
